
    <form class="raising content margin_top_foot">
        <header class="header fixed_top bg_mx_green">
            <div class="back_text" onclick="history.go(-1)"><div class="arrow_left"></div>返回</div>代养详情
            <div class="header_icon">
                <span class="iconfont icon-home"></span>
            </div>
        </header>
        <div class="lists bg_white"></div>
        <button class="fixed_bottom btn_mx_green text_center font_16 lineheight_50" style="border-radius:0">保存</button>
        <div class="contract fixed all bg_dark white padding_15 hide" style="z-index:20">
            <div class="absolute font_18 contract_close" style="right:15px;">
                <div class="iconfont icon-close"></div>
            </div>
            <!--<div class="text_center font_16 lineheight_3">《牧心农业农户代养仔猪合同》</div>-->
            <!--<div class="text_indent lineheight_2">牧心农业农户代养仔猪合同内容</div>-->
        </div>
    </form>
    <div class="toast"></div>
    <!-- toast模版 -->
    <script type="text/template" charset="utf-8" id='toast_template'>
        <i class="iconfont icon-toast{{=it.icon}}"></i>
        <div class="toast_text">{{=it.text}}</div>
    </script>
    <script type="text/template" charset="utf-8" id='list_template'>
        <div class="padding_15 border_b v_center">
            <div class="width_100">
                <img class="fit_img2" src="{{=it.img}}" alt="">
            </div>
            <div class="left_100 padding_l_15 font_12">
                <div>
                    <span class="light">批次：</span>
                    <span class="mx_green">{{=it.pici}}</span>
                </div>
                <div>
                    <span class="light">编号：</span>
                    <span class="mx_green">{{=it.no}}</span>
                </div>
                <div>
                    <span class="light">负责人：</span>
                    <span class="mx_green">{{=it.owner}}</span>
                    <span class="light padding_l_15">品种：</span>
                    <span class="mx_green">{{=it.type}}</span>
                </div>
                <div>
                    <span class="light">父本编号：</span>
                    <span class="mx_green">{{=it.f_no}}</span>
                </div>
                <div>
                    <span class="light">母本编号：</span>
                    <span class="mx_green">{{=it.m_no}}</span>
                </div>
            </div>
        </div>
        <div class="padding_15">
            <div class="flex margin_b_10">
                <div class="width_100">选择代养人</div>
                <div class="left_100">
                    <select name="liveryid" request title="代养人">
                        <option value="0">请选择</option>
                        {{for(var i=0;i<it.farmerlist.length;i++){}}
                        <option value="{{=it.farmerlist[i].id}}" {{if(it.livery==it.farmerlist[i].id){}}selected{{}}}>{{=it.farmerlist[i].name}}</option>
                        {{}}}
                    </select>
                    <input type="hidden" name="liveryname">
                </div>
            </div>
            <div class="margin_b_10">
                <div class="margin_b_10">请输入说明情况</div>
                <div class="border">
                    <textarea class="padding_5" name="liveryremark" rows="5" placeholder="请输入代养说明情况" request title="代养说明情况"><{$pig['liveryremark']}></textarea>
                    <input type="hidden" name="pigid">
                    <input name="_csrf" type="hidden" id="_csrf" value="<{$app->request->csrfToken}>">
                </div>
            </div>
            <!--<div class="font_12"><span class="danger">*</span> 代养成功表示认可<span class="info" onclick="opencontract()">《牧心农业农户代养仔猪合同》</span></div>-->
        </div>
    </script>
    <script>
        // 页面初始化
            var lists = <{$lists}>;
            console.log(lists)
            var evallist = doT.template($("#list_template").text());
            var evalToast = doT.template($("#toast_template").text());
            loaddata(".lists",evallist,lists)
            loadheadbar("代养详情",1)
        // 合同浮层
            function opencontract(){
                $(".contract").slideToggle();
            }
            $(".contract_close").click(function(){
                $(".contract").slideToggle();
            });
        // 提交表单
            var submited = false;
            $(".raising").submit(function(e){
                e.preventDefault();
                var pigid = GetQueryString("pigid");
                $("input[name=pigid]").val(pigid)
                with(this){
                    for (var i = 0; i < this.length; i++) {
                        if($(this[i]).attr("request")==""){
                            if(!checkone(this[i])){
                                return false;
                            }
                        }
                    }
                    $("input[name=liveryname]").val(lists.farmerlist[liveryid.value])
                    if(submited) return false;
                    var data = $(".raising").serialize();
                    $.post("/business/person/post-fill-pig-farmer",data,function(res){console.log(res)
                        submited = true;
                        toast("attention",res.msg);
                        if(!res.status){
                            location.href='/business/person/fill-pig';
                        }
                    },"json")
                }
            })
    </script>


